<template>
  <div>
    <div>
      <van-nav-bar>
        <template #title>
          <div class="qb">
            <p>计价器</p>
          </div>
        </template>
        <template #right></template>
      </van-nav-bar>
    </div>
    <!-- 内容 -->
    <div class="box">
      <div class="mian">
        <div class="mian_1">
          <div class="mian_2">客户目的地</div>
          <div class="mian_3">导航</div>
          <span class="mian_4">
            <input type="text" />
          </span>
        </div>
      </div>
    </div>
    <!-- 里程 -->
    <div class="box_1">
      <div class="box_2">
        <div class="box_3">
          <span class="box_4 spa">行使里程</span>
          <span class="box_s spa">0</span>
          <span class="box_d spa">km</span>
        </div>
        <div class="box_7"></div>
        <div class="box_8">
          <span class="box_9 spa">行使里程</span>
          <span class="box_s spa">0</span>
          <span class="box_d spa">元</span>
        </div>
      </div>
    </div>
    <!-- 接单时间 -->
    <div class="data">
      <span>{{ one }}:{{ two }}:{{ three }}</span>
    </div>
    <div class="btn">
      <div class="btn_1 btn_0" @click="endHandler">中途等待</div>
      <div class="btn_2 btn_0" @click="btn">结束服务</div>
      <div class="btn_kl btn_0" @click="bqar">取消接单</div>
    </div>
    <div class="footer">@快上车代驾</div>
  </div>
</template>

<script>
import { Dialog } from "vant";
export default {
  data() {
    return {
      flag: null,
      one: "00", // 时
      two: "00", // 分
      three: "00", // 秒
      abc: 0, // 秒的计数
      cde: 0, // 分的计数
      efg: 0, // 时的计数
      km: 0,
      many: 0
    };
  },
  props: {
    msg: String
  },
  mounted() {
    this.startHandler();
  },
  methods: {
    // 开始计时
    startHandler() {
      this.flag = setInterval(() => {
        if (this.three === 60 || this.three === "60") {
          this.three = "00";
          this.abc = 0;
          if (this.two === 60 || this.two === "60") {
            this.two = "00";
            this.cde = 0;
            if (this.efg + 1 <= 9) {
              this.efg++;
              this.one = "0" + this.efg;
            } else {
              this.efg++;
              this.one = this.efg;
            }
          } else {
            if (this.cde + 1 <= 9) {
              this.cde++;
              this.two = "0" + this.cde;
            } else {
              this.cde++;
              this.two = this.cde;
            }
          }
        } else {
          if (this.abc + 1 <= 9) {
            this.abc++;
            this.three = "0" + this.abc;
          } else {
            this.abc++;
            this.three = this.abc;
          }
        }
      }, 100);
    },
    // 暂停计时
    endHandler() {
      this.flag = clearInterval(this.flag);
    },
    btn() {
      this.flag = clearInterval(this.flag);
      this.$router.push("/jiazai");
    },
    bqar() {
      Dialog.confirm({
        title: "取消接单",
        message: "本次的接单真的要取消吗？?"
      })
        .then(() => {
          // console.log("确认");
          this.$router.push("/delete");
        })
        .catch(() => {
          // console.log("取消");
        });
    }
  }
};
</script>
</script>

<style scoped>
.mian {
  margin-top: 20px;
  height: 60px;
  overflow: hidden;
}
.mian_1 {
  width: 90%;
  margin: 0 auto;
}
.mian_2 {
  float: left;
}
.mian_3 {
  float: right;
  margin-right: 20px;
  width: 50px;
  height: 25px;
  line-height: 25px;
  text-align: center;
  border: 2px solid orange;
  border-radius: 20px;
  color: orange;
}
.mian_4 {
  display: block;
  width: 100%;
  height: 30px;
  overflow: hidden;
  border-bottom: 2px solid black;
}
.mian_4 input {
  outline: none;
  border: none;
}
.box_1 {
  width: 100%;
}
.box_2 {
  width: 90%;
  margin: 90px auto 0;
  overflow: hidden;
}
.box_3 {
  margin-top: 10px;
  width: 49%;
  float: left;
}
.box_7 {
  margin: 0 auto;
  float: left;
  width: 2px;
  height: 130px;
  background: plum;
}
.box_8 {
  margin-top: 10px;
  width: 49%;
  float: right;
}
.spa {
  display: block;
  width: 100px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  margin: 0 auto;
}
.box_s {
  color: blueviolet;
  font-size: 30px;
  font-weight: bold;
  margin-top: 10px;
}
.box_d {
  margin-top: -5px;
}
.data {
  width: 90%;
  height: 30px;
  margin: 70px auto 0;
  line-height: 30px;
  text-align: center;
  font-size: 20px;
}
.btn {
  width: 90%;
  margin: 40px auto 0;
}
.btn_0 {
  width: 100%;
  height: 50px;
  margin: 0 auto;
  text-align: center;
  background: skyblue;
  line-height: 50px;
  color: #fff;
}
.btn_1 {
  background: red;
}
.btn_kl {
  background: blue;
  margin-top: 20px;
}
.btn_2 {
  background: skyblue;
  margin-top: 20px;
}
.footer {
  position: fixed;
  bottom: 5px;
  font-size: 10px;
  color: aqua;
  width: 100%;
  text-align: center;
}
</style>